package main

import (
	"MdfServer/config"
	"MdfServer/internal/room/biz"
	"MdfServer/internal/room/data"
	"MdfServer/internal/room/service"

	"github.com/go-kratos/kratos/v2"
	"github.com/go-kratos/kratos/v2/log"
	"github.com/go-redis/redis/v8"
)

func main() {
	// 加载配置
	cfg := config.Load()
	// 创建Redis客户端
	redisClient := redis.NewClient(cfg.Redis.ToRedisOptions())
	// 初始化数据层
	repo := data.NewRoomRepo(redisClient)
	// 初始化实时推送（开发环境用空实现）
	realtime := &biz.NopRealtimeUseCase{}
	// 初始化服务
	svc := service.NewRoomService(repo, realtime, log.DefaultLogger)
	// 启动Kratos服务
	app := kratos.New(
		kratos.Name("room-service"),
		kratos.Server(svc.NewGRPCServer()),
	)
	if err := app.Run(); err != nil {
		log.Error(err)
	}
}
